using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using TitanX;

//修改位移，的统一管理类
public class PlayerWaitBoxManger :MonoBehaviour
{

    //首先，我要给诞生一个动画，让它更顺滑一些
    //分为内层和外层，内4 外4
    public GameObject[] innerWaitBox;

    public GameObject[] outsideWaitBox;

    private GameObject[] allWaitBox;

    private Animator animator;

    private AnimatorStateInfo animatorInfo;
    private float animatorInfoTime;

    public bool isPlay;
    public bool isShow;





    public static  PlayerWaitBoxManger Instance;


     private void Awake(){
        animator = transform.GetChild(0).transform.GetComponent<Animator>();

        Instance = this;
     }


    private void Start()
    {

        

    }

    public void Show(){
        transform.GetChild(0).gameObject.transform.position = Player.Instance.player.transform.position;



        transform.GetChild(0).gameObject.SetActive(true);



        for (int i = 0; i < transform.GetChild(0).transform.childCount; i++)
        {
            transform.GetChild(0).GetChild(i).gameObject.SetActive(true);
        }

        //这里建议，直接用动画器
        //主要是你写逻辑，没啥意义


        // animator.speed=1;

    }


private void update(){


        for (int i = 0; i < transform.GetChild(0).childCount; i++)
        {
            transform.GetChild(0).transform.rotation = Camera.main.transform.rotation;
        }


        if (isPlay){

        animatorInfo = animator.GetCurrentAnimatorStateInfo(0);

        animatorInfoTime = animatorInfo.normalizedTime;
        if (animatorInfo.normalizedTime >= 0.95f && animatorInfo.IsName("展开"))
                    {
                        
                    
                        isPlay = false;
                         animator.SetBool("isShow", false);
                    }


    }


}



public void Hide(){

        for (int i = 0; i < transform.GetChild(0).transform.childCount; i++)
        {
            transform.GetChild(0).GetChild(i).GetComponent<PlayerWaitBox>().clearState();
        }

        transform.GetChild(0).gameObject.SetActive(false);

        //动画到 实在不行就去做事件吧，一个固定的场景个，转移
       
        //清楚全部的状态

        /*
        animator.speed=-1;

        animator.SetBool("isShow", true);*/

    
        


}



}

